package logic

import (
	"context"
	"novel-mgr1/userrpc/userrpc"

	"novel-mgr1/api/internal/svc"
	"novel-mgr1/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommentListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCommentListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentListLogic {
	return &CommentListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CommentListLogic) CommentList(req *types.CommentListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	list, err := l.svcCtx.UserRpc.CommentList(l.ctx, &userrpc.CommentListRequest{
		Nid: req.Nid,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil

	}
	return &types.Response{
		Message: "查询成功",
		Data:    list,
		Code:    200,
	}, nil
}
